package com.b1502.store2.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.b1502.store2.R;
import com.b1502.store2.activity.Account_securityActivity;
import com.b1502.store2.activity.AddressActivity;
import com.b1502.store2.activity.EvaluateActivity;
import com.b1502.store2.activity.My_couponActivity;
import com.b1502.store2.activity.My_favoriteActivity;
import com.b1502.store2.activity.My_indentActivity;
import com.b1502.store2.activity.My_pointsActivity;
import com.b1502.store2.activity.SecedeActivity;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link UserInfoFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class UserInfoFragment extends BaseFragment implements View.OnClickListener {
    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;
    private FragmentActivity activity;


    public UserInfoFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment UserInfoFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static UserInfoFragment newInstance(String param1, String param2) {
        UserInfoFragment fragment = new UserInfoFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_user_info, container, false);
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        activity = getActivity();
        LinearLayout All_orders = (LinearLayout) activity.findViewById(R.id.All_orders);
        LinearLayout payment = (LinearLayout) activity.findViewById(R.id.payment);
        LinearLayout Receiving = (LinearLayout) activity.findViewById(R.id.Receiving);
        LinearLayout evaluate = (LinearLayout) activity.findViewById(R.id.evaluate);
                /*** **/
        LinearLayout address = (LinearLayout) activity.findViewById(R.id.address);
        LinearLayout my_favorite = (LinearLayout) activity.findViewById(R.id.my_favorite);
        LinearLayout my_points = (LinearLayout) activity.findViewById(R.id.my_points);
        LinearLayout my_coupon = (LinearLayout) activity.findViewById(R.id.my_coupon);
                /*** **/
        LinearLayout account_security = (LinearLayout) activity.findViewById(R.id.account_security);
        LinearLayout secede = (LinearLayout) activity.findViewById(R.id.secede);



        All_orders.setOnClickListener(this);
        payment.setOnClickListener(this);
        Receiving.setOnClickListener(this);
        evaluate.setOnClickListener(this);
        address.setOnClickListener(this);
        my_favorite.setOnClickListener(this);
        my_points.setOnClickListener(this);
        my_coupon.setOnClickListener(this);
        account_security.setOnClickListener(this);
        secede.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.All_orders:
                startActivity(new Intent(getActivity(), My_indentActivity.class));
                break;
            case R.id.payment:
                startActivity(new Intent(getActivity(), My_indentActivity.class));
                break;
            case R.id.Receiving:
                startActivity(new Intent(getActivity(), My_indentActivity.class));
                break;
            case R.id.evaluate:
                startActivity(new Intent(getActivity(), EvaluateActivity.class));
                break;
            case R.id.address:
                startActivity(new Intent(getActivity(), AddressActivity.class));
                break;
            case R.id.my_favorite:
                startActivity(new Intent(getActivity(), My_favoriteActivity.class));
                break;
            case R.id.my_points:
                startActivity(new Intent(getActivity(), My_pointsActivity.class));
                break;
            case R.id.my_coupon:
                startActivity(new Intent(getActivity(), My_couponActivity.class));
                break;
            case R.id.account_security:
                startActivity(new Intent(getActivity(), Account_securityActivity.class));
                break;
            case R.id.secede:
                startActivity(new Intent(getActivity(), SecedeActivity.class));
                break;


        }
    }
}
